@echo off

setlocal enabledelayedexpansion

call ..\setEnv.bat

set info_m=
set /a ret=0

echo create dir - db
if exist ..\download_file rd /S /Q ..\download_file
mkdir ..\download_file

echo download from %down_location_prefix% begining ... ...

if not exist %down_location_prefix% (
  echo downpload path is not exist, please check again.
  goto err_1
)

if not exist ..\version_list.txt (
  echo ..\version_list.txt not exist, no version info, please check again.
  goto err_1
)

FOR /F "eol=# skip=1" %%i in (..\version_list.txt) do (
set  vers=%%i
echo download - %%i ... ...
mkdir ..\download_file\db\%%i
if exist %down_location_prefix%\%%i\%down_location_postfix% (
  xcopy %down_location_prefix%\%%i\%down_location_postfix% ..\download_file\db\%%i /E /Y >nul
  echo download - %%i completed ... ... 
) else (
  echo [warning]path: %down_location_prefix%\%%i\%down_location_postfix% is not exist.
  echo copy dummy version to - %%i
  xcopy .\dummy ..\download_file\db\%%i /E /Y >nul
  echo download[dummy] - %%i completed ... ...
)


)

:succ_1
echo download from %down_location_prefix% completed ... ...
set info_m=without errors.
set /a ret=100
goto finish

:err_1
echo download !vers! error occurred.
set info_m=with errors.
set /a ret=-100

:finish
echo finish !info_m!

exit !ret!

endlocal